babl-palette: speed up closest-color search
authorEll <ell_se@yahoo.com>
Fri, 18 May 2018 12:04:52 +0000 (08:04 -0400)
committerEll <ell_se@yahoo.com>
Fri, 18 May 2018 12:13:33 +0000 (08:13 -0400)
commit55ca45c8233af138d3fd388587b203d802b8396c
tree5dabead4ee40fcdf7d792c4e6d9c36443b887067
parente3dda81e47376665c0034fe0bcd45e35601470df
babl-palette: speed up closest-color search

When constructing a palette format, calculate the distance between
each pair of colors in the palette, and for each color, construct a
list of all other colors and their distances from it, sorted by
distance.  When searching for the closest palette color to a given
input pixel, based on the assumption that nearby pixels have
similar color, use the color list of the previous pixel's best
match, and use the triangle inequality to stop the search early.

See the code comments for more details.
babl/babl-palette.c